import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.List;

public class Main {
    public static void main(String[] args) throws InterruptedException {
       test01();
    }
    //test01方法
    public static void test01() throws InterruptedException {
        WebDriverManager.chromedriver().setup();
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--remote-allow-origins=*");
        WebDriver driver = new ChromeDriver(options);
        Thread.sleep(3000);
        // 访问百度首页
        driver.get("https://www.baidu.com");
        Thread.sleep(3000);
        List<WebElement> list = driver.findElements(By.cssSelector("#hotsearch-content-wrapper > li> a > span.title-content-title"));
        for(WebElement element:list){
            System.out.println(element.getText());
        }
        Thread.sleep(3000);
        // 关闭浏览器
        driver.quit();

//        driver.findElement(By.cssSelector("#kw")).sendKeys("李易峰");
//        driver.findElement(By.cssSelector("#su")).click();
//        Thread.sleep(3000);
    }
}